package org.kineticsproject.application.util;


import java.io.File;
import java.io.IOException;
import org.eclipse.emf.ecore.resource.impl.*;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
import org.eclipse.emf.common.util.*;
import data.DataPackage;
import data.Person;

public class EnumeratePerson {

	/**
	 * @param args
	 */
	public static void main(String[] args) throws IOException {

		DataPackage dataPackage = DataPackage.eINSTANCE;
		
		//Create new ResourceSet & Resource
		ResourceSet resourceSet = new ResourceSetImpl();
		
		// Register XML resource factory
		resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("xmi", 
		new XMIResourceFactoryImpl());

		Resource resource = resourceSet.createResource(URI.createFileURI(new File("myPerson.xmi").getAbsolutePath()));

		// register package in local resource registry
		resourceSet.getPackageRegistry().put(dataPackage.getNsURI(), dataPackage);
		// load resource 
		resource.load(null);
		
		Person person = (Person)resource.getContents().get(0);
		System.out.println("Name: "+person.getName());
		System.out.println("Height: "+person.getHeight());
		System.out.println("Weight: "+person.getWeight());
		System.out.println("Birth Date: "+person.getDateOfBirth()+"\n");
		


	}

}